package com.my.study.designPatterns.compoundPattern;

public class DuckSimulator4 {


    public static void main(String[] args) {

        DuckSimulator4 duckSimulator4 = new DuckSimulator4();
        duckSimulator4.simulate(new CounterDuckFactory());
    }





    public void simulate(AbstractDuckFactory abstractDuckFactory){
        Quackable green = abstractDuckFactory.greenDuck();
        Quackable red = abstractDuckFactory.redDuck();
        Quackable yellow = abstractDuckFactory.yellowDuck();

        Quackable goose = new GooseAdapter(new Goose());
        System.out.println("------DuckSimulatorOnePattern---------");
        makeQuack(green);
        makeQuack(red);
        makeQuack(yellow);
        makeQuack(goose);


        System.out.println("================");
        Flock flock = new Flock();
        flock.add(green);
        flock.add(yellow);
        flock.add(red);
        flock.add(goose);
        //flock.quack();

        makeQuack(flock);

        System.out.println("quack times: " + QuackCounter.numberOfQuack);
    }


    private void makeQuack(Quackable quackable){

        quackable.quack();
    }

}
